import React from 'react'
import { useLocation, useNavigate } from 'react-router-dom'
import { Button } from '../../../node_modules/antd'
// import { Button, Space } from 'antd';
export default function Herder(props) {
    // console.log(props);
    // const [search, setSearch] = useSearchParams()
    const { state: { id, name } } = useLocation()
    const navigate = useNavigate()
    // const id = search.get('id')
    // const name = search.get('name')
    const pushdata = (e) => {
        if (e.keyCode !== 13) {
            return
        } else {
            const newlist = { id: Date.now(), name: e.target.value, done: true }
            props.a(newlist)
        }
    }

    const herder = () => {
        navigate('/herder', {
            state: {
                id: '0', name: 'a'
            }
        })
        console.log(6);
    }
    const img = () => {

    }
    return (
        <div>
            <button type="primary" onClick={herder} >Herder</button>
            <button onClick={img}  >Img</button>
            <input onKeyUp={pushdata} ></input>
            {id}{name}
        </div>
    )
}




